<?php

namespace App\Admin\Actions\Grid\GoodsOrder;

use App\Models\Shopwindow;
use Dcat\Admin\Grid\BatchAction;
use Dcat\Admin\Widgets\Modal;
use Illuminate\Http\Request;
use App\Admin\Forms\GoodsOrder\GoodsOrderForm;

class CreateOrder extends BatchAction
{
    /**
     * @return string
     */
    protected $title = '创建订单';

    public function handle(Request $request)
    {
        //$form = AuditForm::make();
/*
        $user = User::query()->where('id', '=', $this->getKey())->first();
        if ($user->device && $user->device_number) {
            DisableDeviceModel::disable($user->device, $user->device_number);
        }
*/



        $keys = $this->getKey();
        $goods_ids = Shopwindow::query()->whereIn('id',$keys)->get()->pluck('goods_id');

        //$form = GoodsOrderForm::make();

        return $this
            ->response()
            ->success(trans('admin.succeeded'))
            ->refresh();



    }

    protected function getModalScript(): string
    {
        return <<<JS
var key = {$this->getSelectedKeysScript()}
$('#batch-ids').val(key);
/*
$('.field_payment_address_id').change(function (){
    var id = $(this).val();
    $.ajax({
        type: 'GET',
        url: '/admin/payment-address-key',
        data: {'id':id},
        dataType: 'json',
        success: function (data){
            $(".field_key").val(data.data.key)
        }
    });

});
 */
JS;

    }
}
